
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加商品</title>
    <link rel="stylesheet" href="./static/common/layui/css/layui.css">
    <link rel="stylesheet" href="./static/admin/css/style.css">
    <script src="./static/common/layui/layui.js"></script>
    <script src="./static/common/jquery-3.3.1.min.js"></script>
    <script src="./static/common/vue.min.js"></script>
</head>
<body>
<div id="app">
    <!--顶栏-->
    <header>
        <h1 v-text="webname"></h1>
        <div class="breadcrumb">
            <i class="layui-icon">&#xe715;</i>
            <ul>
                <li v-for="vo in address">
                    <a  v-text="vo.name" :href="vo.url" ></a> <span>/</span>
                </li>
            </ul>
        </div>
    </header>

    <div class="main" id="app">
        <!--左栏-->
        <div class="left">
            <ul class="cl" >
                <!--顶级分类-->
                <li v-for="vo,index in menu" :class="{hidden:vo.hidden}">
                    <a href="javascript:;"  :class="{active:vo.active}"  @click="onActive(index)">
                        <i class="layui-icon" v-html="vo.icon"></i>
                        <span v-text="vo.name"></span>
                        <i class="layui-icon arrow" v-show="vo.url.length==0">&#xe61a;</i> <i v-show="vo.active" class="layui-icon active">&#xe623;</i>
                    </a>
                    <!--子级分类-->
                    <div v-for="vo2,index2 in vo.list">
                        <a href="javascript:;" :class="{active:vo2.active}" @click="onActive(index,index2)" v-text="vo2.name"></a>
                        <i v-show="vo2.active" class="layui-icon active">&#xe623;</i>
                    </div>
                </li>
            </ul>
        </div>
        <!--右侧-->
        <div class="right" id="orderDetail">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>订单详情</legend>
            </fieldset>


            <form id="form" class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">订单号</label>
                    <div class="layui-input-block">
                        <input  name="orderNumber" v-model="order.orderNumber" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">下单时间</label>
                    <div class="layui-input-block">
                        <input v-model="order.createDtm" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input name="name" v-model="order.name" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">电话</label>
                    <div class="layui-input-block">
                        <input name="phone" v-model="order.phone" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">地址</label>
                    <div class="layui-input-block">
                        <input name="address" v-model="order.address" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">产品名</label>
                    <div class="layui-input-block">
                        <input v-model="order.proName" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>


                <fieldset class="layui-elem-field layui-field-title">
                    <legend>操作</legend>
                </fieldset>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <div class="layui-input-inline">
                            <select name="status">
                                <option value="0">未发货</option>
                                <option value="1">已发货</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">物流公司</label>
                    <div class="layui-input-block">
                        <input name="logisticsCompanies" v-model="order.logisticsCompanies" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">运单号</label>
                    <div class="layui-input-block">
                        <input name="waybillNum" v-model="order.waybillNum" type="text" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="addProduct">立即提交</button>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>


<script src="./static/admin/js/config.js"></script>
<script src="./static/admin/js/script.js"></script>
<script>

    layui.use(['form'], function() {

        var id = GetQueryString("id")
        $.ajax({
            url:"/watchsystem/order/select",
            method:'post',
            data:{
                "id":id
            },
            success:function (data) {

                vue.order = data.data
                console.log(vue.order)
            }
        })

        var form = layui.form;
        //监听提交
        form.on('submit(addProduct)', function(data){
            // layer.msg(JSON.stringify(data.field));
            console.log("提交")
            var field = data.field
            console.log(field)
            $.ajax({
                url:"/watchsystem/order/update",
                data:vue.order,
                method:'post',
                success:function (data) {
                    console.log(data)
                    layer.msg(data.msg)
                }
            })
            return false;
        });


    })

    /**
     * 获取请求参数
     * @param name
     * @returns {string|null}
     * @constructor
     */
    function GetQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
</script>
</body>
</html>
